package com.vogue.supplymall.order.domain.provider;

import com.vogue.ssm.database.provider.BaseSqlProvider;
import com.vogue.ssm.database.util.DealStatus;
import com.vogue.supplymall.common.domain.dto.OrderDetailInfo;

/**
 * The type Order item sql provider.
 *
 * @aouthor: zhangliang
 * @date: Create in 2018-02-09
 */
public class OrderItemSqlProvider extends BaseSqlProvider {

    /**
     * Find string.
     *
     * @param detailInfo the detail info
     * @return the string
     */
    public String find(OrderDetailInfo detailInfo) {
        StringBuilder sql = new StringBuilder();
        sql.append(" SELECT ")
                .append(" oi.itemquantity, ")
                .append(" oip.attrplanid ");
        sql.append(" FROM ")
                .append(" product_attrplan pa, ")
                .append(" order_item oi, ")
                .append(" order_item_product oip ");
        sql.append(" WHERE ")
                .append(" oi.orderid = #{orderid} ")
                .append(" AND oi.id = oip.orderitemid ")
                .append(" AND oi.orderid = oip.orderid ")
                .append(" AND oip.attrplanid = pa.id ");
        return DealStatus.formatShadeSql(sql.toString());
    }
}
